<script>
	import Vue from 'vue'
	let __timerId = 0;
	export default {
		onLaunch: function() {
			uni.getSystemInfo({
				success: e=> {
					this.initSize(e);
				}
			})
		},
		methods: {
			//登录状态
			async initLogin(){
				const token = uni.getStorageSync('uniIdToken');
				if(token){
					this.$store.commit('setToken', {
						token
					});
				}
			},
			/**
			 * 存储设备信息 参考colorUI
			 * @param {Object} 
			 */
			initSize(e){
				const systemInfo = e;
				let navigationBarHeight;
				let custom = {};
				// #ifndef MP
				custom = {height: 36,width: 88};
				navigationBarHeight = 44;
				// #endif
				// #ifdef MP
				custom = wx.getMenuButtonBoundingClientRect();
				navigationBarHeight = custom.bottom + custom.top - e.statusBarHeight * 2;
				// #endif	
				systemInfo.custom = custom;
				systemInfo.navigationBarHeight = navigationBarHeight;
				Vue.prototype.systemInfo = systemInfo;
			},
			//打开全局定时器
			openTimer(){
				this.closeTimer();
				__timerId = setInterval(()=>{
					this.$store.commit('setStateAttr', {
						key: 'timerIdent',
						val: !this.$store.state.timerIdent
					})
				}, 1000)
			},
			//关闭定时器
			closeTimer(){
				if(__timerId != 0){
					clearInterval(__timerId);
					__timerId = 0;
				}
			},
		},
		onShow: function() {
		  console.log('App Show')
		  this.openTimer();
		},
		onHide: function() {
			this.closeTimer();
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import url("./common/css/common.css");
	@import url("./common/css/icon.css");
	
	.lazyload{
		position: relative;
		
		&.lazypic{
			&:after{
				content: '';
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				background-image: url();
				background-size: 100% 100%;
				opacity: 0.3;
			}
		}
		image{
			position: relative;
			z-index: 1;
			opacity: 0;
		}
		&.loaded image{
			transition: .7s;
			opacity: 1 !important;
		}
	}
</style>